package com.WISSC.serviceImpl;

import com.WISSC.bean.User;
import com.WISSC.bean.WebPage;
import com.WISSC.bean.layuiBean.ResultPage;
import com.WISSC.bean.layuiBean.VoPage;
import com.WISSC.mapper.WebPageMapper;
import com.WISSC.service.WebPageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class WebPageServiceImpl extends ServiceImpl<WebPageMapper, WebPage> implements WebPageService  {

    @Override
    public ResultPage<WebPage> selectMyPage(VoPage voPage) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("page", (voPage.getPage() - 1) * voPage.getLimit());
        paramMap.put("limit", voPage.getLimit());

        List<WebPage> list = baseMapper.selectMyPage(paramMap);
        Integer count = baseMapper.countMyPage(paramMap);
        ResultPage<WebPage> resultPage = new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);

        return resultPage;
    }

    @Override
    public List<WebPage> selectAll() {
        return baseMapper.selectAll();
    }
}
